<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <script type="text/javascript">
      var systemColumnInfoTable;
  </script>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- 当前位置 begin -->
        <div class="row h-home-path">
          <div class="col-md-12 col-sm-12 col-lg-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">${systemTableInfo.tableName}字段信息</li>
            </ol>
          </div>
        </div>
        <!-- 当前位置 end -->

        <!-- 查询筛选内容 bagin -->
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="col-md-1 col-sm-1 col-xs-1 text-right">
              <label class="control-labe h-form-label" for="columnCode">字段编码：</label>
            </div>
            <div class="col-md-2 col-sm-2 col-xs-2">
              <input class="form-control" id="columnCode" name="columnCode" type="text" value=""/>
            </div>
            <div class="col-md-1 col-sm-1 col-xs-1 text-right">
              <label class="control-labe h-form-label" for="columnName">字段名称：</label>
            </div>
            <div class="col-md-2 col-sm-2 col-xs-2">
              <input class="form-control" id="columnName" name="columnName" type="text" value=""/>
            </div>
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" onclick="SystemColumnInfoManager.search()" type="button"><i
                      class="fa fa-search">&nbsp;&nbsp;</i>查询
              </button>
              <a class="btn btn-primary" href="javascript:SystemColumnInfoManager.addSystemColumnInfo()"
                 type="button"><i class="fa fa-plus">&nbsp;&nbsp;</i>新增</a>
              <a class="btn btn-primary" href="javascript:SystemColumnInfoManager.returnIndex()" type="button"><i
                      class="fa fa-reply">&nbsp;&nbsp;</i>返回</a>
              <button class="btn btn-default" type="reset"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>重置</button>
            </div>
          </form>
        </div>

        <!-- 表格 begin -->
        <div class="panel panel-white h-panel">
          <input id="tableId" name="tableId" type="hidden" value="${systemTableInfo.id!}"/>
          <div class="h-table-header">
            <a class="btn btn-primary" href="javascript:SystemColumnInfoManager.importColumnInfo()" type="button"><i
                    class="fa fa-plus">&nbsp;&nbsp;</i>导入字段信息</a>
          </div>
          <div class="panel-body">
            <table class="table table-striped table-bordered table-hover text-center" id="systemColumnInfo_table"
                   style="width:100%"></table>
          </div>
        </div>
        <!-- 表格 end -->
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->

</div>
<#include "/common/jslib.html">

<script type="text/javascript">
    $(function () {
        SystemColumnInfoManager = {
            init: function () {
            },
            search: function () {
                var queryCond = {
                    columnCode: $("#columnCode").val(),
                    columnName: $("#columnName").val()
                };
                systemColumnInfoTable.options.queryCond = queryCond;
                var tableId = systemColumnInfoTable.options.tableId;
                $(tableId).DataTable().draw();
            },
            addSystemColumnInfo: function () {
                var tableId = $("#tableId").val();
                window.location.href = "/systemColumnInfo/to-form?operation=add&moduleId=${moduleId!}&tableId=" + tableId;
            },
            deleteSystemColumnInfo: function (url, id) {
                var data = {
                    "id": id
                };
                Jmts.deleteItem("确定要删除吗？", url, data, function (result) {
                    if (result.success) {
                        Jmts.succTips("删除成功");
                      SystemColumnInfoManager.search();
                    }
                });
            },
            //返回到表模型
            returnIndex: function () {
                window.location.href = "/systemTableInfo/query?moduleId=${moduleId!}";
            },
            importColumnInfo: function () {
                var tableId = $("#tableId").val();
                var url = "/systemColumnInfo/to-importColumnInfo?tableId=" + tableId + "&&moduleId=${moduleId!}";
                Jmts.openDialog("columnInfoId", url, "${systemTableInfo.tableName}导入字段", 0, 0, 132);
            }
        }
        SystemColumnInfoManager.init();
    });
</script>
<!-- js -->
<script type="text/javascript">
    (function () {
        // datatable插件
        systemColumnInfoTable = new mi.datatable({
            tableId: '#systemColumnInfo_table',
            headerList: [
                '实体类字段编码',
                '实体类字段名称',
                '实体类字段类型',
                '数据库字段编码',
                '数据库字段类型',
                '是否主键',
                '数据字典编码',
                '操作'
            ],
            headerName: [
                'columnCode',
                'columnName',
                'columnTypeCn',
                'columnSqlCode',
                'columnSqlTypeCn',
                'isPkCn',
                'dictCode',
                'operate'
            ],
            createdRow: function (row, data, dataIndex) {
                $(row).children('td').eq(0).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(1).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(2).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(3).attr('style',
                    'text-align:left;');
                $(row).children('td').eq(4).attr('style',
                    'text-align:left;');
            },
            ajaxUrl: '/systemColumnInfo/listSystemColumnInfo?tableId=${systemTableInfo.id!}',
            queryCond: function () {

            },
            columnDefs: [
                {}
            ],
            dataSrc: function (data) {
                var newArr = [];
                for (var i in data) {
                    var id = data[i]['id'];
                    var delbtnDtr = mi.markLink({
                        href: "javascript:SystemColumnInfoManager.deleteSystemColumnInfo('/systemColumnInfo/delete','" + id + "');",
                        txt: '删除  ',
                        className: 'js-del-row-btn btn_operate',
                        data: [
                            {id: id}
                        ]
                    });
                    var updatebtnDtr = mi.markLink({
                        href: '/systemColumnInfo/to-form?id=' + id + "&operation=edit&moduleId=${moduleId!}",
                        txt: '修改',
                        className: 'js-del-row-btn',
                        data: [
                            {id: id}
                        ]
                    });
                    var viewDtr = mi.markLink({
                        href: '/systemColumnInfo/to-form?id=' + id + "&operation=view&moduleId=${moduleId!}",
                        className: 'js-del-row-btn',
                        txt: '  查看',
                        data: [
                            {id: id}
                        ]
                    });
                    data[i]['operate'] = updatebtnDtr + delbtnDtr + viewDtr;
                }
                return data;
            }
        });
    })();
</script>
</body>
</html>
